package com.st.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class AppListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent sce)  {
    	System.out.println("Application对象销毁");
    	
    }

    public void contextInitialized(ServletContextEvent sce)  { 
    	System.out.println("Application对象初始化");
    	
    	// 初始化当前在线人数
    	ServletContext app = sce.getServletContext();
    	app.setAttribute("onlineCount", 0);
    	// 初始化当前登录人数
    	app.setAttribute("loginCount", 0);
    }
}
